﻿//商品评论
window.operateEvents = {
    'click .shpl': function (e, value, row, index) {
        MyDialog.viewform("SpeList/MangnerSPLB.html?PID=" + row.ID, "管理商品子类别");
    }
};
var option = {};
option.columns = [
             {
                 field: 'ID',
                 title: '序号'
             }, {
                 sortable: true,
                 field: 'PID',
                 title: '对应商品'
             }, {
                 field: 'Comment',
                 title: '评论内容',
             }, {
                 field: 'CheckState',
                 title: '审核操作',
                 formatter: function (value, row) {
                     var html = "";
                     if (row.CheckState == "0") {
                         html = '<a href="#" style="margin-left:10px" class="aspsh" status="1" plid="' + row.ID + '" >通过</a><a href="#" style="margin-left:10px" class="aspsh" status="2" plid="' + row.ID + '" >不通过</a>';
                     }
                     return html;
                 },
                 events: operateEvents
             }, {
                 field: 'CheckUser',
                 title: '审核状态',
                 formatter: function (value, row) {
                     var html = '';
                     if (row.CheckState == "0") {
                         html = "<span class='shtext'>待审核</span>";
                     } else if (row.CheckState == "1") {
                         html = "<span class='shtext'  style='color:Green'>审核已通过</span> ";
                     } else {
                         html = "<span class='shtext' style='color:Red'>审核未通过</span>";
                     }
                     return html;
                 }
             }
];
$(document).ready(function () {
    $(".addForm,.EditForm").remove();
    $(".aspsh").live('click', function () {
        var $dom = $(this);
        var plid = $(this).attr("plid");
        var status = $(this).attr("status");
        $.get("../SpeList/DLLAjaxHandler.ashx?Action=PLSH", { id: plid, status: status },
    function (data) {
        if (data == "success") {
            toastr.success("操作成功");
            $(".shtext", $dom.parent().parent()).text(status == 1 ? "审核已通过" : "审核未通过");
            $(".aspsh", $dom.parent()).remove();

        } else {
            toastr.error("操作失败");
        }
    });
    })
})

